home *** CD-ROM | disk | FTP | other *** search
- /* OS header-reading routine courtesy of Ken Badertscher -- 6/27/93 sb */
-
- /*
- With some versions of the Atari hard disk driver, the OS header was
- copied into RAM by the driver so that it could find the date a system
- was built in order to add OS pool. Unfortunately, the way it copied
- the header obliterated the `os_conf' word in the RAM OS header. The
- `os_conf' word tells you which country the TOS version was built for.
- If you need to find out what country your program is running in, you
- must check the ROM copy of the OS header. You can get the address of
- the ROM os header by dereferencing the pointer `os_beg' in the RAM OS
- header, and you can get the address of the RAM OS header from the
- system variable `_sysbase', located at 0x4f2.
-
- This is the structure of the OS header (it is also described in the
- Hitchhiker's Guide to the BIOS, on page 55, in the section entitled
- "PUNTAES and the OS Header (Gory Details)"):
- */
-
- #include <osbind.h>
-
- typedef struct _os_header { /* offset description */
- /* --- -------------------------------- */
- unsigned short os_entry; /* $00 BRA to reset handler */
- unsigned short os_version; /* $02 TOS version number */
- void *reseth; /* $04 -> reset handler */
- struct _os_header *os_beg; /* $08 -> base of OS */
- void *os_end; /* $0c -> end BIOS/GEMDOS/VDI ram usage */
- void *os_rsv1; /* $10 << unused, reserved >> */
- void *os_magic; /* $14 -> GEM memory usage parm. block */
- long os_date; /* $18 Date of system build ($MMDDYYYY) */
- unsigned short os_conf; /* $1c OS configuration bits */
- unsigned short os_dosdate; /* $1e DOS-format date of system build */
- /* The next three fields are only available in TOS versions 1.2 and greater */
- void **p_root; /* $20 -> base of OS pool */
- char **pkbshift; /* $24 -> keyboard shift state variable */
- void **p_run; /* $28 -> GEMDOS PID of current process */
- void *p_rsv2; /* $2c << unused, reserved >> */
- } OSHEADER;
-
- #define SYSBASE ((OSHEADER **)(0x4f2L))
-
- unsigned int GetTOSvers(long *OS_date, unsigned int *OS_conf,
- unsigned int * OS_dosdate)
- {
- /* Get the RAM OS header, then use it to get at the "real"
- * OS header, since the RAM one doesn't contain a valid
- * os_conf word with some hard disk drivers.
- */
- register void *savestack = (void *)Super(0L);
- register OSHEADER *os_header = *SYSBASE;
- Super(savestack);
- os_header = os_header->os_beg;
- if (OS_date)
- *OS_date = os_header->os_date;
- if (OS_conf)
- *OS_conf = os_header->os_conf;
- if (OS_dosdate)
- *OS_dosdate = os_header->os_dosdate;
- return os_header->os_version;
- }
-